@import "../../theme/var.scss";

$height: 64px;

.header {
  position: relative;
  width: 100%;
  height: $height;
  z-index: 1003;
}

.wrapper {
  width: 100vw;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg);
  transition: all .3s;

  &.affix {
    position: fixed;
    z-index: 100;
    transform: translateY(-100%);

    &.visible {
      transform: translateY(0);
    }
  }

  &.boxShadow {
    box-shadow: var(--box-shadow);
  }

  > div {
    position: relative;
    display: flex;
    align-items: center;
  }

  .logo {
    height: $height;
    line-height: $height;
    text-align: left;
    color: var(--main-text-color);
    margin-right: 2rem;

    img {
      display: inline-block;
      height: 36px;
    }
  }

  .mobileTrigger {
    display: none;
    position: absolute;
    right: 15px;

    .stick {
      width: 25px;
      height: 4px;
      background-color: var(--primary-color);
      opacity: 1;
      border-radius: var(--border-radius);
      transition: all 250ms ease-in-out 0s;

      &:nth-of-type(2) {
        margin: 5px 0;
      }
    }

    &.active {
      .stick {
        &:first-of-type {
          transform: translateY(9px) rotate(45deg);
        }

        &:nth-of-type(2) {
          opacity: 0;
        }

        &:last-of-type {
          transform: translateY(-9px) rotate(-45deg);
        }
      }
    }
  }

  nav {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--main-text-color);
    font-size: 16px;

    ul {
      width: 100%;
      position: relative;

      li {
        display: inline-flex;
        padding: 0;
        vertical-align: middle;
        line-height: 64px;
        padding: 0 16px;

        &:first-of-type {
          padding-left: 0;
        }

        &.active {
          color: var(--primary-color);
        }

        a {
          color: inherit;
          width: 100%;
        }
      }

      .searchWrapper,
      .themeToggle {
        float: right;
        margin-top: 32px;
        transform: translateY(-50%);
      }

      .search {
        display: inline-block;
        width: 24px;
        height: 24px;
        background: url("")
          100% 50% no-repeat;
        cursor: pointer;
        transform: translateY(-1px);
      }

      .themeToggle {
        float: right;
      }

      @media (max-width: 768px) {
        li {
          text-align: center;

          &:first-child {
            margin-top: 24px;
          }
        }

        .searchWrapper,
        .themeToggle {
          float: none;
          margin-top: 0;
          transform: translateY(0);
        }

        .search,
        .themeToggle button {
          margin: 12px auto;
        }
      }
    }
  }

  @media (max-width: 768px) {
    nav {
      position: absolute;
      top: 100%;
      left: 0;
      z-index: 100;
      width: 100vw;
      padding: 0 15px;
      max-height: 0;
      overflow: hidden;
      transition: max-height 0.25s;
      margin-left: 0;
      background-color: var(--bg);

      &.active {
        max-height: 100vh;
        overflow: auto;
        border-top: 1px solid var(--border-color);
        border-bottom: 1px solid var(--border-color);
      }

      ul {
        width: 100%;

        li {
          display: flex;
          padding: 0;
          line-height: 48px;
        }
      }
    }
  }

  @media (max-width: 768px) {
    .mobileTrigger {
      display: block;
    }
  }
}
